-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[No QA][TS Migration] Add comments for remaining properties in Onyx types #41956
[No QA][TS Migration] Add comments for remaining properties in Onyx types #41956
Conversation
src/types/onyx/Policy.ts
Outdated
name: string; | ||
}; | ||
|
||
/** | ||
* Data imported from QuickBooks Online. | ||
*/ | ||
type QBOConnectionData = { | ||
/** TODO: I think this value can be changed to `ValueOf<CONST.COUNTRY>` */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting comment here for me to get back to this later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's test it or leave as it is
…-remaining-onyx-types # Conflicts: # src/types/onyx/Policy.ts # src/types/onyx/Report.ts # src/types/onyx/ReportAction.ts
…-remaining-onyx-types # Conflicts: # src/types/onyx/IOU.ts
…-remaining-onyx-types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall a massive improvement, let's aim to get rid of all TODOs in the code and have some internal eyes on the PR 🙌
…-remaining-onyx-types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost LGTM, let's aim to remove all TODOs by either removing the properties or adding minimal context on them.
src/types/onyx/IOU.ts
Outdated
isSender?: boolean; | ||
|
||
/** TODO: I think this type could be changes to `IOUType` */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try it then 👍
src/types/onyx/Report.ts
Outdated
/** TODO: Doesn't exist in the app */ | ||
managerEmail?: string; | ||
|
||
/** TODO: Doesn't exist in the app */ | ||
parentReportActionIDs?: number[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can remove these fields
src/types/onyx/Report.ts
Outdated
text?: string; | ||
|
||
/** TODO: Doesn't exist in the app */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used in the app, let's remove
src/types/onyx/ReportAction.ts
Outdated
/** TODO: Only used in tests */ | ||
whisperedTo?: number[]; | ||
|
||
/** TODO: Only used in tests */ | ||
reactions?: Reaction[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used in src/libs/ReportActionsUtils.ts
, let's add the context for these props
src/types/onyx/ReportAction.ts
Outdated
/** TODO: not enough context, seems to be used in tests only */ | ||
automatic?: boolean; | ||
|
||
/** TODO: Not enough context, seems to be used in tests only */ | ||
shouldShow?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure we could remove both, but it would take a lot of refactor in ReportUtils.ts
and tests. How about marking these as @depracated
with explanation?
src/types/onyx/ReportAction.ts
Outdated
@@ -169,25 +192,52 @@ type ReportActionBase = OnyxCommon.OnyxValueWithOfflineFeedback<{ | |||
/** The user's ID */ | |||
accountID?: number; | |||
|
|||
/** TODO: Doesn't exist in the app */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove if it's not used, same for other TODOs like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking real good, but there are still many properties with TODOs, let's solve them
- Confirming if they need to be there or just remove them
- For the testing properties, remove TODO word and make it clear is used for testing purposes
- For the ones that could be a different type, either test it or leave as it is
src/types/onyx/OriginalMessage.ts
Outdated
type OriginalMessageApproved = { | ||
actionName: typeof CONST.REPORT.ACTIONS.TYPE.APPROVED; | ||
|
||
/** TODO: I think the type should match the scructure of `originalMessage` in `buildOptimisticApprovedReportAction` */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's test this or if not possible, leave unknown
src/types/onyx/OriginalMessage.ts
Outdated
type ReimbursementDeQueuedMessage = { | ||
/** TODO: I'd replace this type with `ValueOf<typeof CONST.REPORT.CANCEL_PAYMENT_REASONS>` */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you test this?
src/types/onyx/OriginalMessage.ts
Outdated
/** TODO: Doesn't exist in the app */ | ||
edits?: string[]; | ||
|
||
/** TODO: Doesn't exist in the app */ | ||
childReportID?: string; | ||
|
||
/** TODO: Doesn't exist in the app */ | ||
isDeletedParentAction?: boolean; | ||
|
||
/** TODO: Doesn't exist in the app */ | ||
flags?: Record<FlagSeverityName, FlagSeverity[]>; | ||
|
||
/** TODO: Doesn't exist in the app */ | ||
moderationDecisions?: Decision[]; | ||
|
||
/** TODO: Only used in tests */ | ||
whisperedTo: number[]; | ||
|
||
/** TODO: Doesn't exist in the app */ | ||
reactions?: Reaction[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's confirm if they have some purpose or just remove from the App, expect whisperedTo
(change the comment to remove TODO)
src/types/onyx/OriginalMessage.ts
Outdated
/** TODO: I think this type could be changed to `ValueOf<typeof CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION>` */ | ||
/** What was the invited user decision */ | ||
choice: string; | ||
|
||
/** TODO: Doesn't exist in the app */ | ||
email: string; | ||
|
||
/** TODO: Doesn't exist in the app */ | ||
inviterEmail: string; | ||
|
||
/** TODO: Only used in tests */ | ||
lastModified: string; | ||
|
||
/** TODO: Doesn't exist in the app */ | ||
policyID: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for the TODOs, confirm to remove the unused, remove TODO word from testing ones
src/types/onyx/OriginalMessage.ts
Outdated
transactionID: string; | ||
|
||
/** TODO: Only used in tests */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove TODO word from testing ones
src/types/onyx/OriginalMessage.ts
Outdated
type OriginalMessageReimbursementDequeued = { | ||
actionName: typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DEQUEUED; | ||
|
||
/** TODO: I think this type should be `ReimbursementDeQueuedMessage` */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either test it or leave as it is
src/types/onyx/Policy.ts
Outdated
type TaxCode = { | ||
/** TODO: Not used in app */ | ||
totalTaxRateVal: string; | ||
|
||
/** TODO: Not used in app */ | ||
simpleName: string; | ||
|
||
/** TODO: Not used in app */ | ||
taxCodeRef: string; | ||
|
||
/** TODO: Not used in app */ | ||
taxRateRefs: Record<string, string>; | ||
|
||
/** TODO: Not used in app */ | ||
/** Name of the tax code */ | ||
name: string; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing is used here? Is this type even being used at all?
src/types/onyx/Policy.ts
Outdated
name: string; | ||
}; | ||
|
||
/** | ||
* Data imported from QuickBooks Online. | ||
*/ | ||
type QBOConnectionData = { | ||
/** TODO: I think this value can be changed to `ValueOf<CONST.COUNTRY>` */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's test it or leave as it is
…-remaining-onyx-types # Conflicts: # src/types/onyx/Policy.ts
…-remaining-onyx-types
@cead22 do you know anyone that can help by providing descriptions to the remaining Xero and Quickbooks online type declarations? Thanks 🙌 |
For properties in Policy that are related to QBO and Xero, I can add comments to them in a follow up PP as discussed here Issue created -> #43033 |
…-remaining-onyx-types # Conflicts: # src/types/onyx/OriginalMessage.ts # src/types/onyx/Transaction.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pac-guerreiro There are still TODOs on these three files, let's get them done and open the PR asap
src/libs/ReportActionsUtils.ts
Outdated
@@ -1205,7 +1205,7 @@ function isActionableJoinRequest(reportAction: OnyxEntry<ReportAction>): reportA | |||
*/ | |||
function isActionableJoinRequestPending(reportID: string): boolean { | |||
const sortedReportActions = getSortedReportActions(Object.values(getAllReportActions(reportID))); | |||
const findPendingRequest = sortedReportActions.find((reportActionItem) => isActionableJoinRequest(reportActionItem) && reportActionItem.originalMessage.choice === ''); | |||
const findPendingRequest = sortedReportActions.find((reportActionItem) => isActionableJoinRequest(reportActionItem) && reportActionItem.originalMessage.choice === '' as ValueOf<typeof CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets create a type for ValueOf<typeof CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION>
and use it here.
if (!isActionableWhisper && (!ReportActionsUtils.isActionableJoinRequest(action) || action.originalMessage.choice !== '')) { | ||
if ( | ||
!isActionableWhisper && | ||
(!ReportActionsUtils.isActionableJoinRequest(action) || action.originalMessage.choice !== ('' as ValueOf<typeof CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION>)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here.
…-remaining-onyx-types # Conflicts: # src/pages/home/report/ReportFooter.tsx
…-remaining-onyx-types # Conflicts: # src/types/onyx/IOU.ts
…-remaining-onyx-types
…r/39129-add-comments-to-remaining-onyx-types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pac-guerreiro Thank you very much, this must have been hard to put together. I am going to merge this now to avoid conflicts but please address my comments in a new PR
amount: number; | ||
|
||
/** Optional comment */ | ||
comment?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB: I think the comment is optional so it can be an empty string but the property would be returned always
comment?: string; | |
comment: string; |
decision: DecisionName; | ||
|
||
/** When was the decision name */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** When was the decision name */ | |
/** When was the decision made */ |
/** Currency of the approved expense amount */ | ||
currency: string; | ||
|
||
/** Report ID of the expense */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have to be a bit careful with use of expense / expense report. Expense = transaction and you can have a transaction thread.
In this case the report action refers to the expense report so we should make it clear to remove any doubts
/** Report ID of the expense */ | |
/** Report ID of the expense report*/ |
|
||
/** Content of the original message */ | ||
originalMessage: { | ||
/** Approved expense amount */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** Approved expense amount */ | |
/** Approved expense report amount */ |
/** Approved expense amount */ | ||
amount: number; | ||
|
||
/** Currency of the approved expense amount */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** Currency of the approved expense amount */ | |
/** Currency of the approved expense report amount */ |
type TransactionViolation = { | ||
/** Type of transaction violation ('violation', 'notice', 'warning', ...) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add these into CONST to get stricter here
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to production by https://github.com/luacmartins in version: 1.4.81-11 🚀
|
Details
This PR aims to add descriptions for every Onyx type and property in the codebase. It also add a ESLint rule to enforces every Onyx type and its properties to have a comment explaining its purpose.
As discussed here, QBO and Xero typings will be handled in a follow up issue.
Fixed Issues
$ #39129
PROPOSAL: N/A
Tests
N/A
Offline tests
N/A
QA Steps
N/A
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
N/A
Android: mWeb Chrome
N/A
iOS: Native
N/A
iOS: mWeb Safari
N/A
MacOS: Chrome / Safari
N/A
MacOS: Desktop
N/A